home *** CD-ROM | disk | FTP | other *** search
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <fcntl.h>
- #include <errno.h>
- #include "crtlocal.h"
-
- #define macTime(t) (t + (time_t)0x7c25b080)
-
- int utimes(const char *name, const struct timeval *buf)
- {
- CInfoPBRec cPB;
- FSSpec canon = hfs_canon(crt_parID, name, 1);
- if (!*canon.name) return -1;
- cPB.hFileInfo.ioNamePtr = canon.name;
- cPB.hFileInfo.ioVRefNum = canon.vRefNum;
- cPB.hFileInfo.ioDirID = canon.parID;
- cPB.hFileInfo.ioFDirIndex = 0;
- if (PBGetCatInfoSync(&cPB))
- {
- errtran(cPB.hFileInfo.ioResult);
- return -1;
- }
- /* last access time, modification time and creation time(?) */
- cPB.hFileInfo.ioFlMdDat = macTime(buf->tv_sec);
- cPB.hFileInfo.ioFlCrDat = macTime(buf->tv_sec);
- cPB.hFileInfo.ioNamePtr = canon.name;
- cPB.hFileInfo.ioVRefNum = canon.vRefNum;
- cPB.hFileInfo.ioDirID = canon.parID;
- cPB.hFileInfo.ioFDirIndex = 0;
- if (PBSetCatInfoSync(&cPB))
- {
- errtran(cPB.hFileInfo.ioResult);
- return -1;
- }
- return 0;
- }
-